<template>
	<view class="parent">
		<text class="title-tip">认证信息仅用于实名认证，会严格保密</text>
		<view class="content">
			<text class="label">真实姓名</text>
			<input :placeholder="nameHint" v-model="name"/>
		</view>
		<view class="content">
			<text class="label">身份证号</text>
			<input :placeholder="idHint" v-model="id"/>
		</view>
		<view class="btn" @click="onSubmit">立即认证</view>
		<view class="tip">
			一个身份信息只能绑定一个账号，证件信息绑定后不能修改。
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name: '',
				id: '',
				nameHint: '请输入姓名',
				idHint: '请输入身份证号',
			}
		},
		methods: {
			onSubmit(){
				if('' == this.name){
					uni.showToast({
						title: this.nameHint,
					})
					return
				}
				if('' == this.id){
					uni.showToast({
						title: this.idHint,
					})
					return
				}
				
				this.requestSave();
			},
			
			async requestSave(){
				let params = {realName: this.name, idNum: this.id};
				let res = await this.$common.post("/app/auth/realNameAuthIos", params);
				if(0 == res.code){
					uni.showToast({
						title: '提交成功',
					});
					uni.navigateBack();
				}else{
					uni.showToast({
						icon:'none',
						title: res.msg,
					});
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.parent{
		display: flex;
		flex-direction: column;
		padding: 50rpx;
		justify-content: center;
		
		.title-tip{
			color: #222;
			font-size: 24rpx;
			text-align: center;
		}
		
		.content{
			display: flex;
			flex-direction: row;
			padding: 0 20rpx;
			align-items: center;
			width: 100%;
			height: 80rpx;
			background-color: #eee;
			border-radius: 20rpx;
			margin-top: 50rpx;
			
			.label{
				color: #222;
				font-size: 30rpx;
				width: 150rpx;
				text-align: center;
			}
			
			input{
				color: #666;
				font-size: 28rpx;
			}
		}
		
		.tip{
			color: #999;
			font-size: 20rpx;
			margin-top: 20rpx;
		}
	}
	
	.btn{
		margin: 100rpx 0 0;
		box-sizing: border-box;
		background-image: linear-gradient(to right, #9fe9ff, #ab7aff);
		border-radius: 40rpx;
		width: 100wh;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		color:white;
	}
</style>
